Lesson 10 - tuples

Tuples work a bit like lists in python. They are immutable, which means they can not change once created, and they have no methods which can be used on them. So why use tuples? The answer is that tuples are faster and offer a way of write-protecting a list. A common source of bugs is when a function alters a list which has been passed which, over time, will become hard to keep track of.

tuple - a immutable list


exTuple = (25, 25, 255)
for i in exTuple
	print i

print exTuple[1]
exTuple[1] = 31 # error, tuples are immutable